//
//  CMDBHomeRelatedPeopleViewController.swift
//  CMDB
//
//  Created by 曹桂祥 on 2017/5/5.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBHomeRelatedPeopleViewController: CMDBBaseViewController {
    
    var tableView : CMDBHomeRelatedTableView!
    
    private let KTitleViewH : CGFloat = 44
    
    override func setup() {
        super.setup()
        
        buildTableView()
        
    }
    
}

extension CMDBHomeRelatedPeopleViewController{
    
    func buildTableView(){
        
        let contentH = CMDB_Screen_Height - KStatusBarHeight - KNavBarHeight - KTitleViewH - KTabBarHeight
        
        view.addSubview(UIView.CreateLine(CGRect(x: 0, y: 0, width: CMDB_Screen_Width, height: 10), lineColor: UIColor.Hex6(0x000000, alpha: 0.12)))
        
        let contentFrame = CGRect(x: 0, y: 10, width: CMDB_Screen_Width, height: contentH)
        
        tableView                              = CMDBHomeRelatedTableView(frame: contentFrame)
        tableView.separatorStyle               = .None
        tableView.showsVerticalScrollIndicator = false
        tableView.mDelegate                    = self
        tableView.controller                   = self
        tableView.backgroundColor              = UIColor.Hex6(0x000000, alpha: 0.12)
        
        view.addSubview(tableView)

    }
    
    func onHeaderRefresh() {
        
        let relatedUsersParam = CMDBGetRelatedUsers2HomeParam()
        
        do{
            try CMDBGetRelatedUser2HomeManage.getInstance.queryHomeRelatedUserList(relatedUsersParam, tableView: tableView, handler: { (homeRelatedUser) in

                    self.tableView.updateDataWithOutReload(homeRelatedUser)
                    self.tableView.updateCellAdpaters(homeRelatedUser!, isInsert: false)

                }, error: { (rescode) in
                    
                }, failure: {
                    
            })
        }catch{
            
        }
        
    }
    
    func onFooterRefresh() {
    
    }
}
